package ocean.service;

import java.awt.Point;

import ocean.data.DataHolder;
import ocean.fauna.I.Fish;
import ocean.service.I.MoveGenerator;

public class FishStepGenerator extends MoveGenerator
{
    protected static int gen()
    {
	return DataHolder.getObjSize() * DataHolder.getGenStepMin()
		+ (int) (Math.random() * ((DataHolder.getGenStepMax() - DataHolder.getGenStepMin()) + 1));
    }

    public static Point getFreePosition(Fish fish)
    {
	Point res = fish.getPosition().getLocation();
	res.setLocation(fish.getPosition().x + gen(), fish.getPosition().y + gen());

	while (!checkLocationForStopObjects(res))
	{
	    if (res.x > 0 && res.x < DataHolder.getOceanWidth() && res.y > 0 && res.y < DataHolder.getOceanHeight())
	    {
		res.setLocation(fish.getPosition().x + gen(), fish.getPosition().y + gen());
	    }
	}

	return res;

    }

}
